package com.zfei.gfb.request;

import com.zfei.gfb.bean.Const;
import com.zfei.gfb.bean.Status;
import com.zfei.gfb.bean.StatusException;
import com.zfei.gfb.util.ObjUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;


/**
 * @author fgh
 */
@Data
public class H5JobAddRequest {

    @ApiModelProperty(value = "岗位名称", required = true)
    private String name;
    @ApiModelProperty(value = "岗位薪资，xx元/天，可以是区间", required = true)
    private String salary;
    @ApiModelProperty(value = "招聘人数", required = true)
    private Integer headCount;
    @ApiModelProperty(value = "联系人电话", required = true)
    private String linkPhone;
    @ApiModelProperty(value = "岗位描述", required = true)
    private String content;
    @ApiModelProperty(value = "所在地区", required = true)
    private String zone;
    @ApiModelProperty(value = "地图坐标", required = true)
    private String point;
    @ApiModelProperty(value = "发布者", required = false)
    private String userName;
    @ApiModelProperty(value = "结算方式", required = true)
    private String settleMethod;

    public void checkInsertNull() {
        if (ObjUtil.anyNull(name, salary, headCount, linkPhone, content, zone, point,settleMethod)) {
            throw new StatusException(Status.INVALID_ARGUMENT);
        }
        if (StringUtils.isAnyBlank(name, salary, content, zone)) {
            throw new StatusException(Status.INVALID_ARGUMENT);
        }
        if (headCount <= 0) {
            throw new StatusException(Status.INVALID_ARGUMENT);
        }
        if (content.length() > Const.CONTENT_LENGTH) {
            throw new StatusException(Status.INVALID_ARGUMENT);
        }
    }

}

